<HTML><HEAD><TITLE>?Vars &:: +Domain</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(sd)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>?Vars &:: +Domain</H1>
All elements of Vars have a value in the domain Domain
<DL>
<DT><EM>Vars</EM></DT>
<DD>Variable or atomic value, list of them, or submatrix of them
</DD>
<DT><EM>Domain</EM></DT>
<DD>List of atomic values, or domain name (atom)
</DD>
</DL>
<H2>Description</H2>
<P>
	Constrains a variable (or a list of variables, or a submatrix of
	variables), to have the domain Domain.  The domain is specified
	simply as an unordered list of atomic values.  A domain variable
	can only be instantiated to values within its domain.
	</P><P>
	For compatibility with library(ic_symbolic), domains can also be
	pre-declared using domain/1, and domain variables then declared
	by just giving the domain name rather than the list of values.
	Note however that even in this case the domain is considered
	unordered, i.e. the order of domain elements in the declaration
	is not important for the purposes of this library.
	</P><P>
	Note that, on the left hand side of &amp;::/2, the atom [] is not
	interpreted as the empty list (of variables or values), but as
	a single atomic value, i.e. a potential domain element.
	This is in keeping with the behaviour of the ic_symbolic
	library, but in contrast with the behaviour of numeric solvers
	such as ic.
	</P>

<H3>Modules</H3>
This predicate is sensitive to its module context (tool predicate, see @/2).
<H2>Examples</H2>
<PRE>
    ?- X &amp;:: [mo, tu, we, th, fr, sa, su].
    X = X{[fr, mo, sa, su, th, tu, we]}
    Yes (0.00s cpu)

    ?- [X,Y,we] &amp;:: [mo, tu, we, th, fr, sa, su].
    X = X{[fr, mo, sa, su, th, tu, we]}
    Y = Y{[fr, mo, sa, su, th, tu, we]}
    Yes (0.00s cpu)

    ?- dim(M, [3]), M[1..3] &amp;:: [a,e,i,o,u].
    M = [](_354{[a,e,i,o,u]}, _364{[a,e,i,o,u]}, _374{[a,e,i,o,u]})
    Yes (0.00s cpu)

    ?- [X,Y] &amp;:: [we,fr,su].
    X = X{[we, fr, su]}
    Y = Y{[we, fr, su]}

    ?- X &amp;:: [].
    No (0.00s cpu)

    % Using a named, pre-declared domain
    ?- local domain(colour(r, g, b)).
    Yes (0.01s cpu)

    ?- X &amp;:: colour.
    X = X{[b, g, r]}
    Yes (0.00s cpu)
    </PRE>
<H2>See Also</H2>
<A HREF="../../lib/sd/indomain-1.html">indomain / 1</A>, <A HREF="../../lib/sd/get_domain_as_list-2.html">get_domain_as_list / 2</A>, <A HREF="../../lib/sd/get_domain_size-2.html">get_domain_size / 2</A>, <A HREF="../../kernel/termcomp/domain-1.html">domain / 1</A>
</BODY></HTML>
